﻿<Popup x:Class="UniversalEditor.Modules.TabSwitchModule.TabSwitchView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			xmlns:tabSwitchModule="clr-namespace:UniversalEditor.Modules.TabSwitchModule"
       xmlns:converters="clr-namespace:UniversalEditor.Base.Utils.Converters;assembly=UniversalEditor.Base"
       mc:Ignorable="d" d:DataContext="{x:Static tabSwitchModule:TabSwitchViewModel.Designer}"
             d:DesignHeight="300" d:DesignWidth="300" IsOpen="{Binding IsOpen, Mode=TwoWay}" AllowsTransparency="True">
	<Popup.Resources>
		<converters:ExtensionToImageSourceConverter x:Key="PathToImageSourceConverter"/>
	</Popup.Resources>
	
	<Border BorderBrush="{x:Static SystemColors.ActiveBorderBrush}" BorderThickness="1" Background="{x:Static SystemColors.ControlBrush}" Width="{Binding MaxWidth}">
		<Grid>
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="*"/>
				<RowDefinition Height="Auto"/>
			</Grid.RowDefinitions>

			<Rectangle Grid.Row="0" Fill="DodgerBlue" Height="2"/>
			<TextBlock Text="{Binding ElementName=list, Path=SelectedItem.FileName}" FontSize="16" FontWeight="Bold" TextTrimming="CharacterEllipsis" Grid.Row="1" Margin="5,0,5,0" />
			
			<TextBlock Text="Active Files:" Grid.Row="2" FontWeight="Bold" Margin="5, 0, 5, 0"/>

			<TextBlock Text="{Binding ElementName=list, Path=SelectedItem.DisplayFilePath}" Grid.Row="4" Margin="5, 0, 5, 10" TextTrimming="CharacterEllipsis"/>

			<ListBox x:Name="list" Grid.Row="3" Background="{x:Static SystemColors.ControlBrush}" ItemsSource="{Binding OpenedEditors}" SelectionMode="Single" 
					  SelectedIndex="{Binding SelectionIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding SelectedEditor, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
					  Margin="5, 10, 5, 10">
				<ListBox.Resources>
					<Style TargetType="{x:Type ListBoxItem}">
						<Setter Property="Template">
							<Setter.Value>
								<ControlTemplate TargetType="{x:Type ListBoxItem}">
									<Border x:Name="Bd" Cursor="{x:Static Cursors.Hand}" Background="Transparent" Width="186">
										<StackPanel Orientation="Horizontal">
											<Image Source="{Binding FileName, Converter={StaticResource PathToImageSourceConverter}}" Height="16" Margin="2,2,5,2"/>
											<TextBlock Text="{Binding FileName}" Tag="{Binding}" PreviewMouseDown="UIElement_OnMouseUp" VerticalAlignment="Center"/>
										</StackPanel>
									</Border>
									<ControlTemplate.Triggers>
										<Trigger Property="IsSelected" Value="True">
											<Setter Property="Foreground" Value="White"/>
											<Setter TargetName="Bd" Property="Background" Value="DodgerBlue"/>
										</Trigger>
									</ControlTemplate.Triggers>
								</ControlTemplate>
							</Setter.Value>
						</Setter>
					</Style>
				</ListBox.Resources>
				<ListBox.Template>
					<ControlTemplate>
						<WrapPanel Orientation="Vertical" IsItemsHost="True" MaxHeight="200"/>
					</ControlTemplate>
				</ListBox.Template>
				<ListBox.ItemTemplate>
					<ItemContainerTemplate>
						
					</ItemContainerTemplate>
				</ListBox.ItemTemplate>
			</ListBox>

		</Grid>
	</Border>
</Popup>
